<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>修改社区活动</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../css/xadmin.css">
    <script type="text/javascript" src="../assets/js/jquery-1.8.3.min.js"></script>
    <script src="../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/xadmin.js"></script>

<body>
<div class="layui-fluid">
    <div class="layui-row">
        <div class="layui-form" style="margin-left: 30%">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>ID</label>
                <div class="layui-input-inline">
                    <input type="text" id="aid" maxlength="11" name="username" required="" lay-verify="nikename" autocomplete="off" class="layui-input"></div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>活动类型</label>
                <div class="layui-input-inline">
                    <input type="text" id="atype"  name="username" required="" lay-verify="nikename" autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">
                    <span class="x-red">*</span>标题</label>
                <div class="layui-input-inline">
                    <input type="text" id="atitle" autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">
                    <span class="x-red">*</span>内容</label>
                <div class="layui-input-inline">
                    <input type="text" id="ainfo" name="username" required="" lay-verify="nikename" autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">
                    <span class="x-red">*</span>参与人数</label>
                <div class="layui-input-inline">
                    <input type="text" id="acount" maxlength="3"  autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">
                    <span class="x-red">*</span>开始时间</label>
                <div class="layui-input-inline">
                    <input type="text" id="astartTime" maxlength="3"  autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">
                    <span class="x-red">*</span>结束时间</label>
                <div class="layui-input-inline">
                    <input type="text" id="aendTime" maxlength="3"  autocomplete="off" class="layui-input"></div>
            </div>

            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label"></label>
                <button class="layui-btn" lay-filter="add" id="butt" lay-submit="">增加</button></div>
        </div>
    </div>
</div>
</body>

</html>
<script>
    layui.use(['table','jquery','layer'], function(){
        var table = layui.table;
        var $=layui.jquery;
        layer = layui.layer;
        $.ajax({
            type:'GET',
            url:"http://localhost:8080/api/insert",
            data:{"id":sessionStorage.getItem("aid")},
            headers:{
                token:localStorage.getItem("token")
            },
            datatype: "json",
            success:function (data){
                let aid=sessionStorage.getItem("aid")
                let atype=sessionStorage.getItem("atype")
                let atitle=sessionStorage.getItem("atitle")
                let ainfo=sessionStorage.getItem("ainfo")
                let acount=sessionStorage.getItem("acount")
                let astartTime=sessionStorage.getItem("astartTime")
                let aendTime=sessionStorage.getItem("aendTime")
                $("#aid").val(aid);
                $("#atype").val(atype);
                 $("#atitle").val(atitle);
                $("#ainfo").val(ainfo);
                 $("#acount").val(acount);
                 $("#astartTime").val(astartTime);
                $("#aendTime").val(aendTime);
            }
        })
    })

    $("#butt").click(function (){
        layui.use(['table','jquery','layer'], function(){
            var table = layui.table;
            var $=layui.jquery;
            var layer=layui.layer;
            let aId=$("#aid").val();
            let atype = $("#atype").val();
            let atitle = $("#atitle").val();
            let ainfo = $("#ainfo").val();
            let acount = $("#acount").val();
            let astartTime = $("#astartTime").val();
            let aendTime = $("#aendTime").val();
            $.ajax({
                type:"POST",
                url:"http://localhost:8080/api/xgsq",
                data:{"aId":aId,"aType":atype,"aTitle":atitle,"aInfo":ainfo,"aCount":acount,"aStartTime":astartTime,"aEndTime":aendTime},
                headers:{
                    token:localStorage.getItem("token")
                },
                datatype: "json",
                success:function (data){

                    if (data!=""){
                        var index = parent.layer.getFrameIndex(window.name);
                        layer.msg('修改成功!',{
                            icon:1
                            ,time:800
                        },function (){
                            parent.layer.close(index);//关闭当前页
                        });
                    }
                }
            })
        })
    })
</script>